home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / math / gle-3.000 / gle-3 / gle / fitbez.c < prev    next >
C/C++ Source or Header  |  1995-02-07  |  2KB  |  71 lines

  1. #include "all.h"
  2. #include <math.h>
  3.  
  4. #if (defined M_PI && !defined PI)
  5. #define PI M_PI
  6. #define pi M_PI
  7. #elif defined PI
  8. #define pi PI
  9. #else
  10. #define PI 3.141592653
  11. #define pi 3.141592653
  12. #endif
  13.  
  14.  
  15. int polar_xy(double r, double angle, double *dx, double *dy);
  16. int xy_polar(double dx,double dy,double *radius,double *angle);
  17.  
  18. int glefitcf_(int32 *mode,float *x, float *y, int32 *l, int32 *m, float *u, float *v, int32 *n);
  19. fitbez(double **pxv, double **pyv, int **pmv,int *pnp, int multivalued)
  20. {
  21.     double *xv, *yv;
  22.     int *m;
  23.     int n,i;
  24.     float *xin,*yin,*xout,*yout,*xx,*yy,*xxout,*yyout;
  25.     int32 mode,nsub,outp,ninp;
  26.  
  27.  
  28.     if (*pnp>138  || *pnp<=2) return;
  29.     xin = myallocz(*pnp*sizeof(*xin));
  30.     yin = myallocz(*pnp*sizeof(*xin));
  31.     xout = myallocz(300*sizeof(*xin));
  32.     yout = myallocz(300*sizeof(*xin));
  33.     xxout = xout; yyout = yout;
  34.     /* myfree(*pmv); */
  35.     *pmv = myallocz(300*sizeof(i));
  36.  
  37.     xv = *pxv;
  38.     yv = *pyv;
  39.     xx = xin; yy = yin;
  40.     for (i=0;i<*pnp;i++) {
  41.         *xx++ = *xv++;
  42.         *yy++ = *yv++;
  43.     }
  44.     mode = 1;
  45.     if (multivalued) mode=2;
  46.     nsub = 280/(*pnp-1);
  47.     outp = 300;
  48.     outp = (*pnp-1)*nsub+1;
  49.     ninp = *pnp;
  50.     glefitcf_(&mode,xin,yin,&ninp,&nsub,xout,yout,&outp);
  51.     xv = myallocz(300*sizeof(*xv));
  52.     yv = myallocz(300*sizeof(*xv));
  53.     /* myfree(*pxv);     myfree(*pyv); */
  54.     *pxv = xv;
  55.     *pyv = yv;
  56.     *pnp = outp;
  57.     for (i=0;i<*pnp;i++) {
  58.         *xv++ = *xout++;
  59.         *yv++ = *yout++;
  60.     }
  61.     /* should call FREE to deal old points */
  62.     m = *pmv;
  63.     for (i=0;i<=*pnp;i++) *m++ = 0;    /* no missing values */
  64.  
  65.     myfree(xin);
  66.     myfree(yin);
  67.     myfree(xxout);
  68.     myfree(yyout);
  69. }
  70.  
  71.